﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_ucGridViewFileLists : System.Web.UI.UserControl
{
    public string Text
    {
        get { return HiddenID.Value; }
        set { HiddenID.Value = value; }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(HiddenID.Value))
        {
            string savepath = Server.MapPath(ConfigurationManager.AppSettings["UploadFilePath"].ToString() + HiddenID.Value);
            if (!System.IO.Directory.Exists(savepath))
            {
                System.IO.Directory.CreateDirectory(savepath);
            }
            System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(savepath);
            GVFileLists.DataSource = d.GetFiles();
            GVFileLists.DataBind();        
        }
           
    }

    protected void GVFileLists_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink link = (HyperLink)e.Row.FindControl("Link_Download");
            Label lbl_Name = (Label)e.Row.FindControl("lbl_Name");
            link.Text = lbl_Name.Text;
            link.NavigateUrl = string.Format("~/Announcement/DownloadHandler.ashx?Fn={0}&Bid={1}"
                , lbl_Name.Text, HiddenID.Value);
        }

    }
}